//  Copyright Druid Mechanics


#include "AbilitySystem/Abilities/AuraGameplayAbility.h"

#include "AbilitySystem/AuraAttributeSet.h"

FString UAuraGameplayAbility::GetDescription(int32 Level)
{
	return FString::Printf(
		TEXT("<Default>%s, </><Level>%d</>"),
		L"Default Ability Name - LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum LoremIpsum ",
		Level);
}

FString UAuraGameplayAbility::GetNextLevelDescription(int32 Level)
{
	return FString::Printf(TEXT("<Default>Next Level: </><Level>%d</> \n<Default>Causes much more damage. </>"), Level);
}

FString UAuraGameplayAbility::GetLockedDescription(int32 Level)
{
	return FString::Printf(TEXT("<Default>Spell Locked Until Level: %d</>"), Level);
}

float UAuraGameplayAbility::GetManaCost(float InLevel) const
{
	float ManaCost = 0.f;
	/**
	 * GetCostGameplayEffect: 返回用于Cost的GE。
	 */
	if(const UGameplayEffect* CostEffect = GetCostGameplayEffect())
	{
		/**
		 * Modifiers: 用于影响此GE的Target的Modifier数组。
		 */
		for(FGameplayModifierInfo Mod : CostEffect->Modifiers)
		{
			/**
			 * Attribute: 我们所修改的属性，或者我们所修改的GE所进行修改的属性。  
			 */
			if(Mod.Attribute == UAuraAttributeSet::GetManaAttribute())
			{
				/**
				 * GetStaticMagnitudeIfPossible: 返回被输入到数据中的量值(就是常量)。仅用于缩放数据或其它不需要上下文就可以获取的任意类型数据。
				 */
				Mod.ModifierMagnitude.GetStaticMagnitudeIfPossible(InLevel, ManaCost);
				break;
			}
		}
	}
	return ManaCost;
}

float UAuraGameplayAbility::GetCooldown(float InLevel) const
{
	float Cooldown = 0.f;
	/**
	 * GetCooldownGameplayEffect: 返回用于确定Cooldown的GE。
	 */
	if(const UGameplayEffect* CooldownEffect = GetCooldownGameplayEffect())
	{
		/**
		 * DurationMagnitude: 持续秒数。0是立即效果；-1是永久持续。
		 */
		CooldownEffect->DurationMagnitude.GetStaticMagnitudeIfPossible(InLevel, Cooldown);
	}
	return Cooldown;
}
